package com.leyou.gateway.config;

import com.leyou.auth.utils.RsaUtils;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.security.PublicKey;

/**
 * @program: leyou
 * @author: Li Wenwen
 * @create: 2019-01-26 17:18
 */
@Data
@Configuration
@ConfigurationProperties("ly.jwt")
public class JwtProperties {
    private String pubKeyPath;
    private String cookieName;
    private PublicKey publicKey;

    //对象一旦实例化后,就应该读取公钥和私钥
    @PostConstruct
    public void init() throws Exception{
        //读取公钥私钥
        this.publicKey = RsaUtils.getPublicKey(pubKeyPath);
    }
}
